<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" th:href="@{/bootstrap-4.6.0-dist/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/bootstrap-4.6.0-dist/css/bootstrap-icons.css}">
    <script th:src="@{/js/jquery.min.1.10.2.js}"></script>
    <style type="text/css">
        .content {
            margin: 15px;
        }

        .tol {
            margin-bottom: 15px;
        }
    </style>
</head>


<body>
<div class="content">
    <div class="tol">
        <a class="btn  btn-outline-info" href="/add.html">新增</a>
    </div>
    <table class="table table-hover">
        <thead class="thead-dark">
        <tr>
            <th>#</th>
            <th>学院名称</th>
            <th>学院说明</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="item : ${listAcademyDO}">
            <td th:text="${item.id}"></td>
            <td th:text="${item.name}"></td>
            <td th:text="${item.description}"></td>
            <td>
                <a class="btn btn-danger btn-sm" th:onclick="deleteAcademy([[${item.id}]])">删除</a>
                <a class="btn btn-info btn-sm" th:onclick="editAcademy([[${item.id}]])">修改</a>
            </td>
        </tr>
        </tbody>
    </table>

</div>

</body>

<script>
    $(function () {

    });

    function deleteAcademy(id) {
        var flag = confirm("确定要删除吗？")
        if (flag) {
            $.ajax({
                type: "GET",
                url: "/delete/" + id,
                success: function (html) {
                    alert(html)
                    location.reload(true)
                },
            })
        }
    }

    function editAcademy(id) {
        $.ajax({
            type: "GET",
            url: "/edit/" + id,
            success: function (html) {
                window.location.href = "/edit/" + id
            },
        })
    }
</script>
</html>
